package com.itheima.methodinference;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

public class ConstructorMethodDemo {
    public static void main(String[] args){
        // 匿名内部类
        CarFactory factory = new  CarFactory() {
            @Override
            public Car createCar(String name) {
                return new Car(name);
            }
        };

        // Lambda表达式
        CarFactory factory2 = name -> new Car(name);

        // 构造器引用
        CarFactory factory1 = Car::new;
    }

}

interface CarFactory{
    Car createCar(String name);
}
@Data
@AllArgsConstructor
@NoArgsConstructor
class Car{
    private String name;
}